from pptx import Presentation


def extract_ppt_text(file_path):
    ppt = Presentation(file_path)
    text_list = []
    for slide in ppt.slides:
        for shape in slide.shapes:
            if hasattr(shape, "text"):
                text_list.append(shape.text)
    all_text = "\n".join(text_list)
    return all_text


# 主程序入口，进行测试调用
if __name__ == "__main__":
    # 指定要读取的Word文件名
    file_path = "example.pptx"
    # 调用函数提取Word文本
    result = extract_ppt_text(file_path)
    # 打印提取到的文本内容
    print(result)
